home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / lmemset.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  667 b   |  39 lines

  1. #ifdef __GNUC__
  2. #ifdef __MSHORT__
  3. #include "lib.h"
  4.  
  5. /*
  6.  * memset - set bytes
  7.  *
  8.  * CHARBITS should be defined only if the compiler lacks "unsigned char".
  9.  * It should be a mask, e.g. 0377 for an 8-bit machine.
  10.  */
  11.  
  12. #ifndef CHARBITS
  13. #    define    UNSCHAR(c)    ((unsigned char)(c))
  14. #    define  uchar        unsigned char
  15. #else
  16. #    define    UNSCHAR(c)    ((c)&CHARBITS)
  17. #    define  uchar        char
  18. #endif
  19.  
  20. _VOIDSTAR
  21. lmemset(s, ucharfill, size)
  22. _VOIDSTAR s;
  23. register int ucharfill;
  24. long size;
  25. {
  26.     register uchar *scan;
  27.     register long n;
  28.     register int uc;
  29.  
  30.     scan = s;
  31.     uc = UNSCHAR(ucharfill);
  32.     for (n = size; n > 0; n--)
  33.         *scan++ = uc;
  34.  
  35.     return(s);
  36. }
  37. #endif /* __MSHORT__ */
  38. #endif /* __GNUC__   */
  39.